<template>
	<view>
		<view class="head">
			<u-icon name="/static/airConditioner/light.png" size="30"></u-icon>空调24小时开放
		</view>
		<view class="airConditioner">
			<image src="/static/airConditioner/air_conditioner.png" mode=""></image>
			<view class="air">
				<view class="" v-if="showAir">
					<image :src="snow?'/static/airConditioner/snow.png':hot?'/static/airConditioner/hot.png':''"
						class="airImage"></image>
					<view class="fontAir">
						{{sum}}°C
					</view>
				</view>
			</view>
		</view>
		<view class="icons">
			<image src="/static/airConditioner/snow.png" :class="snow?'image':''" @click="snow=!snow;hot=false;sum=24">
			</image>
			<image src="/static/airConditioner/close.png" :class="showAir?'image1':''" @click="isShowAir"></image>
			<image src="/static/airConditioner/hot.png" :class="hot?'image2':''" @click="hot=!hot;snow=false;sum=30">
			</image>
		</view>
		<view class="icons">
			<view class="icon" @click="addSum">
				<u-icon name="plus" size="80" color="#fff"></u-icon>
			</view>
			<view class="icon" @click="delSum">
				<u-icon name="minus" size="80" color="#fff"></u-icon>
			</view>
		</view>
		<view class="fen" v-if="showAir">
			<view class="fen1"> </view>
			<view class="fen2"> </view>
			<view class="fen3"> </view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				sum: 24,
				snow: false,
				showAir: false,
				hot: false,
				innerAudioContext: uni.getBackgroundAudioManager()
			}
		},
		onLoad() {
			// this.isInnerAudioContext()
		},
		methods: {
			delSum() {
				if (this.showAir == true && this.sum > 17) {
					this.sum--
				}
			},
			addSum() {
				if (this.showAir == true && this.sum < 30) {
					this.sum++
				}
			},
			isInnerAudioContext() {
				wx.playBackgroundAudio({
				  dataUrl: 'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-f260e183-a2a9-4d40-ae13-c8daaf1987da/2264cafd-47eb-44f1-a45e-7d74b7bbdc46.mp3',
				})
			},
			isShowAir() {
				this.showAir = !this.showAir
				if (this.showAir == true && this.snow == true) {
					this.snow = true
					this.isInnerAudioContext()
				} else if (this.showAir == true && this.hot == true) {
					this.hot = true
					this.isInnerAudioContext()
				} else if(this.showAir == false){
					this.hot = false
					this.snow = false
					wx.pauseBackgroundAudio()
				}else {
					var date=new Date()
					var month=date.getMonth()+1
					if(month<=10 &&month>=5){
						this.snow = true
					}else{
						this.hot = true
					}
					this.isInnerAudioContext()
				}
			}
		}
	}
</script>

<style scoped lang="scss">
	.head {
		display: flex;
		align-items: center;
		justify-content: center;
	}

	.airConditioner {
		padding: 20rpx;

		image {
			width: 100%;
			height: 25vh;
		}

		.air {
			position: absolute;
			top: 50px;
			right: 80rpx;
			width: 200rpx;
			height: 5vh;
			display: flex;
			align-items: center;
			background-color: #000;
			border-radius: 20rpx;
			padding-left: 20rpx;
			color: #fff;

			>view {
				display: flex;
			}

			.fontAir {
				padding-left: 15rpx;
				font-size: 40rpx;
			}

			.airImage {
				width: 50rpx;
				height: 50rpx;
				border-radius: 50%;
				box-sizing: border-box;
			}
		}

	}

	.icons {
		display: flex;
		justify-content: space-around;
		flex-wrap: wrap;
		margin: 20rpx;

		.icon {
			display: flex;
			width: 150rpx;
			height: 150rpx;
			border-radius: 50%;
			background-color: #bcbcbc;
			padding-left: 35rpx;
		}

		.icon:active{
			background-color: #515151;
		}

		image {
			background-color: #bcbcbc;
			width: 150rpx;
			height: 150rpx;
			border-radius: 50%;
			padding: 40rpx;
			box-sizing: border-box;
		}

		.image {
			background-color: #60c8ff;
		}

		.image1 {
			background-color: red;
		}

		.image3 {
			background-color: green;
		}

		.image2 {
			background-color: #dd524d;
		}

	}

	.fen {
		position: absolute;
		top: 23vh;
		display: flex;
		justify-content: space-around;
		padding: 0 50rpx;
		width: 100%;
		box-sizing: border-box;

		view {
			background: #c7c7c7;
		}

		.fen1 {
			width: 10rpx;
			height: 100rpx;
			transform: rotate(45deg);
		}

		.fen2 {
			width: 10rpx;
			height: 100rpx;
		}

		.fen3 {
			width: 10rpx;
			height: 100rpx;
			transform: rotate(-45deg);
		}
	}
</style>
